<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.thymeleaf.org" layout:decorator="admin/fragments/layout">
<head>
    <title>权限修改</title>
    <meta name="active" content="apps-center"/>
    <!-- jQuery Validate Plugin-->
    <script th:src="@{/resources/assets/admin-tools/admin-forms/js/jquery.validate.min.js}"></script>

    <!-- jQuery Validate Addon -->
    <script th:src="@{/resources/assets/admin-tools/admin-forms/js/additional-methods.min.js}"></script>

    <!-- FileUpload JS -->
    <script th:src="@{/resources/vendor/plugins/fileupload/fileupload.js}"></script>

    <!-- Required Plugin CSS -->
    <link rel="stylesheet" type="text/css" th:href="@{/resources/vendor/plugins/tagmanager/tagmanager.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/resources/vendor/plugins/daterange/daterangepicker.css}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/resources/vendor/plugins/datepicker/css/bootstrap-datetimepicker.css}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/resources/vendor/plugins/colorpicker/css/bootstrap-colorpicker.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/resources/vendor/plugins/select2/css/core.css}"/>

    <!-- Theme CSS -->
    <link rel="stylesheet" type="text/css" th:href="@{/resources/assets/skin/default_skin/css/theme.css}"/>

    <!-- 提示 PNotify -->
    <script th:src="@{/resources/vendor/plugins/pnotify/pnotify.js}"></script>
</head>
<body>

<header id="topbar" class="ph10" layout:fragment="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-icon crumb-active">
                <a th:href="@{/admin/dashboard}"> <span class="glyphicon glyphicon-home"></span> </a>
            </li>
            <li class="crumb-trail">权限管理</li>
            <li class="crumb-trail"><a href="" th:href="@{/perm/list(pclass=p_6,currentClass=c_8)}">权限列表</a></li>
            <li class="crumb-trail">权限修改</li>
        </ol>
    </div>
</header>

<div layout:fragment="content">
    <div class="theme-primary mw1000 center-block">
        <div class="panel">
            <form method="post" th:action="@{/perm/modify}" th:object="${permission}" id="admin-form">
                <input th:field="*{permissionId}" type="hidden"/>
                <div class="panel-body bg-light">
                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">权限名称:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{name}" class="gui-input" placeholder="权限名称..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">父权限:</span></label>
                        <label class="field prepend-icon">
                            <label class="field select">
                                <select id="parentId" name="parentId" th:field="${permission.parentId}">
                                    <option value="0">根权限</option>
                                    <option th:each="perm : ${allPermission}" th:object="${perm}" th:value="*{permissionId}" th:text="*{name}"></option>
                                </select>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">权限编码:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{code}" class="gui-input" placeholder="权限编码..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">权限:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{permission}" class="gui-input" placeholder="权限..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">URL:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{url}" class="gui-input" placeholder="URL..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">目标属性:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{target}" class="gui-input" placeholder="目标属性..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">图标:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{icon}" class="gui-input" placeholder="图标..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">顺序:</span></label>
                        <label class="field prepend-icon">
                            <input type="text" th:field="*{permissionIndex}" class="gui-input" placeholder="顺序..."/>
                            <label class="field-icon">
                                <i class="fa fa-credit-card"></i>
                            </label>
                        </label>
                    </div>

                    <div class="admin-form form-group">
                        <label class="tipLabel"><span class="tipTitle">功能性:</span></label>
                        <label class="field prepend-icon">
                            <label class="field select">
                                <select id="type" th:field="*{isFunction}">
                                    <option th:value="B0T" th:selected="selected">是</option>
                                    <option th:value="B0F" th:selected="selected">否</option>
                                </select>
                            </label>
                        </label>
                    </div>

                </div>
                <!-- end .form-body section -->
                <div class="panel-footer text-right">
                    <button type="submit" class="btn btn-primary btn-sm" id="submitInput"> 保存</button>
                    <button type="button" onclick="javascript:history.go(-1);" class="btn btn-primary btn-sm"> 返回
                    </button>
                </div>
                <!-- end .form-footer section -->
            </form>

        </div>
    </div>
</div>

<script type="text/javascript" th:inline="javascript" layout:fragment="javascript">
    /*<![CDATA[*/
    jQuery(document).ready(function () {
        $("#admin-form").validate({
            errorClass: "state-error",
            validClass: "state-success",
            errorElement: "em",
            rules: {
                parentId: {
                    required: true,
                    minlength:1,
                    maxlength:20
                },
                name: {
                    required: true,
                    minlength:1,
                    maxlength:100
                },
                code: {
                    required: true,
                    minlength:1,
                    maxlength:100
                },
                permissionIndex: {
                    required: true,
                    minlength:1,
                    maxlength:10
                },
                isFunction: {
                    required: true,
                    minlength:1,
                    maxlength:10
                }
            },
            messages: {
                parentId: {
                    required: '请选择父权限',
                    minlength: '最少1个字',
                    maxlength: '最长20个字'
                },
                name: {
                    required: '请输入权限名称',
                    minlength: '最少1个字',
                    maxlength: '最长100个字'
                },
                code: {
                    required: '请输入权限编码',
                    minlength: '最少1个字',
                    maxlength: '最长100个字'
                },
                permissionIndex: {
                    required: '请输入顺序',
                    minlength: '最少1个字',
                    maxlength: '最长10个字'
                },
                isFunction: {
                    required: '请选择是否功能性菜单',
                    minlength: '最少1个字',
                    maxlength: '最长10个字'
                }
            },
            submitHandler: function(form) {
                form.submit();
            },
            highlight: function (element, errorClass, validClass) {
                $(element).closest('.field').addClass(errorClass).removeClass(validClass);
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).closest('.field').removeClass(errorClass).addClass(validClass);
            },
            errorPlacement: function (error, element) {
                if (element.is(":radio") || element.is(":checkbox")) {
                    element.closest('.option-group').after(error);
                } else {
                    error.insertAfter(element.parent());
                }
            }
        });
    });
    /*]]>*/
</script>
</body>
</html>